import request from '@/router/axios';
import {baseUrl} from '@/config/env';

export const list = (data) => {
    return request({
            url: baseUrl + '/start/sysUser/page',
            method: 'get',
            data: data
        }
    )
}
export const add = (data) => {
    return request({
            url: baseUrl + '/start/sysUser/add',
            method: 'post',
            data: data
        }
    )
}

export const updateById = (id,data,index) => {
    return request({
            url: baseUrl + '/start/sysUser/updateById',
            method: 'put',
            data: data
        }
    )
}
export const deleteById = (id) => {
    return request({
            url: baseUrl + '/start/sysUser/deleteById/' + id,
            method: 'delete',
        }
    )
}

/**
 * 下载导入模板
 * @returns {*}
 */
export const downloadTemplate = () => {
    return request({
            url: baseUrl + '/start/sysUser/downloadTemplate',
            method: 'get',
            responseType: 'blob'
        }
    )
}
/**
 * 导出excel
 * @param data
 * @returns {*}
 */
export const exportExcel = (data) => {
    return request({
            url: baseUrl + '/start/sysUser/exportExcel',
            method: 'get',
            responseType: 'blob',
            data: data
        }
    )
}
/**
 * 导入excel
 * @param data
 * @returns {*}
 */
export const importExcel = (data) => {
    return request({
            url: baseUrl + '/start/sysUser/importExcel',
            method: 'post',
            data: data
        }
    )
}


export const getUserInfo = (id) => {
    return request({
            url: baseUrl + '/start/sysUser/getUserInfo/' + id,
            method: 'get',
        }
    )
}

export const updateUserPassword = ( data) => request({
    url: baseUrl + '/sysUser/updateUserPassword' ,
    method: 'put',
    data: data
})

const userApi={
    list,
    getUserInfo
}

export default userApi
